<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Rails::Generator::NamedBase</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Rails::Generator::NamedBase</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/railties/lib/rails_generator/base_rb.html">
                vendor/rails/railties/lib/rails_generator/base.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Base.html">
                Base
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The base generator for named components: models, controllers, mailers, etc.
The target name is taken as the first argument and inflected to singular,
plural, class, file, and table forms for your convenience. The remaining
arguments are aliased to <tt>actions</tt> as an array for controller and
mailer convenience.
</p>
<p>
Several useful local variables and methods are populated in the
<tt>initialize</tt> method. See below for a list of Attributes and External
Aliases available to both the manifest and to all templates.
</p>
<p>
If no name is provided, the generator raises a usage error with content
optionally read from the USAGE file in the generator&#8216;s base path.
</p>
<p>
For example, the <tt>controller</tt> generator takes the first argument as
the name of the class and subsequent arguments as the names of actions to
be generated:
</p>
<pre>
  ./script/generate controller Article index new create
</pre>
<p>
See <a href="Base.html">Rails::Generator::Base</a> for a discussion of
manifests, <a
href="Commands/Create.html">Rails::Generator::Commands::Create</a> for
methods available to the manifest, and <a
href="../Generator.html">Rails::Generator</a> for a general discussion of
generators.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001873">attributes</a>&nbsp;&nbsp;
      <a href="#M001872">banner</a>&nbsp;&nbsp;
      <a href="#M001871">new</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">



    <div id="aliases-list">
      <h3 class="section-bar">External Aliases</h3>

      <div class="name-list">
                        <table summary="aliases">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">singular_name</td>
          <td>-&gt;</td>
          <td class="context-item-value">file_name</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">args</td>
          <td>-&gt;</td>
          <td class="context-item-value">actions</td>
        </tr>
                        </table>
      </div>
    </div>


    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">class_name</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">class_nesting</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">class_nesting_depth</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">class_path</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">file_path</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">name</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">plural_name</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">singular_name</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">table_name</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M001871" class="method-detail">
        <a name="M001871"></a>

        <div class="method-heading">
          <a href="#M001871" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(runtime_args, runtime_options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001871-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001871-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/rails_generator/base.rb, line 203</span>
203:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">runtime_args</span>, <span class="ruby-identifier">runtime_options</span> = {})
204:         <span class="ruby-keyword kw">super</span>
205: 
206:         <span class="ruby-comment cmt"># Name argument is required.</span>
207:         <span class="ruby-identifier">usage</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">runtime_args</span>.<span class="ruby-identifier">empty?</span>
208: 
209:         <span class="ruby-ivar">@args</span> = <span class="ruby-identifier">runtime_args</span>.<span class="ruby-identifier">dup</span>
210:         <span class="ruby-identifier">base_name</span> = <span class="ruby-ivar">@args</span>.<span class="ruby-identifier">shift</span>
211:         <span class="ruby-identifier">assign_names!</span>(<span class="ruby-identifier">base_name</span>)
212:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M001873" class="method-detail">
        <a name="M001873"></a>

        <div class="method-heading">
          <a href="#M001873" class="method-signature">
          <span class="method-name">attributes</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001873-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001873-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/rails_generator/base.rb, line 220</span>
220:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">attributes</span>
221:           <span class="ruby-ivar">@attributes</span> <span class="ruby-operator">||=</span> <span class="ruby-ivar">@args</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span><span class="ruby-operator">|</span>
222:             <span class="ruby-constant">Rails</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span><span class="ruby-operator">::</span><span class="ruby-constant">GeneratedAttribute</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;:&quot;</span>))
223:           <span class="ruby-keyword kw">end</span>
224:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001872" class="method-detail">
        <a name="M001872"></a>

        <div class="method-heading">
          <a href="#M001872" class="method-signature">
          <span class="method-name">banner</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Override with your own usage <a href="NamedBase.html#M001872">banner</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001872-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001872-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/rails_generator/base.rb, line 216</span>
216:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">banner</span>
217:           <span class="ruby-node">&quot;Usage: #{$0} #{spec.name} #{spec.name.camelize}Name [options]&quot;</span>
218:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>